Skip to content

feat(cli): add @videojs/cli docs command for LLM-friendly installation#1214

Open
decepulis wants to merge 7 commits intomainfrom
feat/docs-cli
Open

feat(cli): add @videojs/cli docs command for LLM-friendly installation#1214
decepulis wants to merge 7 commits intomainfrom
feat/docs-cli

Conversation

@decepulis
Copy link
Copy Markdown
Collaborator

@decepulis decepulis commented Apr 3, 2026

Summary

  • Adds @videojs/cli, a CLI that serves Video.js docs from the command line with codegen for the installation page
  • Extracts codegen logic from site React components into shared pure functions
  • Adds HumanCase/LLMCase Astro components + Turndown rules for browser vs. LLM content splitting
  • CLI reads bundled markdown from site build output, replaces markers with generated code
  • Added to release-please linked-versions group so it's versioned and published with the other packages

Commands

npx @videojs/cli docs how-to/installation --framework react --media hls
npx @videojs/cli docs <slug> --framework <html|react>
npx @videojs/cli docs --list --framework html
npx @videojs/cli config set framework react

Before merging: npm setup

  1. Initialize the package on npm: npm publish --access public manually once from packages/cli/ to create the @videojs/cli package on the registry
  2. Set up trusted publishing: In npm, go to @videojs/cli → Settings → Configure trusted publishing for the GitHub Actions workflow (cd.yml), matching the existing packages
  3. After that, the release-please + CD workflow publishes it automatically alongside the other packages

Closes #1185
Closes #1215

Test plan

  • Run node packages/cli/dist/index.mjs docs how-to/installation --framework html --preset video --install-method npm — verify HTML install output
  • Run node packages/cli/dist/index.mjs docs how-to/installation --framework react --media hls --install-method pnpm — verify React + HLS output
  • Run node packages/cli/dist/index.mjs docs how-to/installation --framework react --install-method cdn — verify invalid combo errors
  • Run node packages/cli/dist/index.mjs docs --list --framework html — verify llms.txt listing
  • Run node packages/cli/dist/index.mjs docs concepts/skins --framework react — verify regular doc passthrough
  • Run interactive mode: node packages/cli/dist/index.mjs docs how-to/installation — verify prompts
  • Dev server: verify installation page pickers still generate identical code
  • pnpm -F site test — 375 tests pass
  • pnpm -F @videojs/cli test — 13 tests pass
  • pnpm turbo run build --filter=@videojs/cli... — full build chain succeeds

🤖 Generated with Claude Code


Note

Medium Risk
Adds a new publishable @videojs/cli package and updates release/CD pipelines to build and ship it, which can affect releases and CI if misconfigured. Also refactors installation code generation paths shared between site and CLI, so mistakes could change the installation docs output for users.

Overview
Adds a new publishable Node CLI package, @videojs/cli, that can docs --list from per-framework llms.txt, print bundled markdown docs, and for how-to/installation interactively/flag-driven generate installation code and replace <!-- cli:replace ... --> markers.

Refactors installation snippet generation into shared pure utilities under site/src/utils/installation/ (new codegen.ts + types.ts) and updates the site’s installation components/stores to consume these shared functions/types instead of embedding ad-hoc codegen.

Updates the LLM markdown build integration to preserve LLMCase content and emit CLI-replace markers (data-llms-only, data-cli-replace), adjusts the installation doc to include HumanCase/LLMCase sections, and wires the CLI into monorepo tooling (release-please manifest/config, cd.yml build step, root scripts/tsconfig, commitlint scope, lockfile, and ignores generated packages/cli/docs/).

Reviewed by Cursor Bugbot for commit ec049dc. Bugbot is set up for automated code reviews on this repo. Configure here.

Introduces `@videojs/cli`, a CLI that serves Video.js documentation from
the command line with special handling for the installation page. LLMs
and humans can generate framework-specific installation code via flags
instead of the interactive web pickers that break in plain text.

Key changes:

- Extract codegen logic from site React components into pure functions
  (`site/src/utils/installation/codegen.ts`) shared by both the site
  and CLI
- Add `HumanCase`/`LLMCase` Astro components and Turndown rules so
  `installation.mdx` serves different content to browsers vs. the LLM
  markdown pipeline
- Create `packages/cli/` with `docs`, `config` commands, interactive
  prompts via @clack/prompts, and flag parsing via @bomb.sh/args
- CLI builds bundled docs from site's LLM markdown output at build time

Closes #1185

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@netlify
Copy link
Copy Markdown

netlify bot commented Apr 3, 2026

Deploy Preview for vjs10-site ready!

Name Link
🔨 Latest commit ec049dc
🔍 Latest deploy log https://app.netlify.com/projects/vjs10-site/deploys/69d95506b208e500086ffa2f
😎 Deploy Preview https://deploy-preview-1214--vjs10-site.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 3, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
v10-sandbox Ready Ready Preview, Comment Apr 10, 2026 7:53pm

Request Review

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 3, 2026

📦 Bundle Size Report

🎨 @videojs/html — no changes
Presets (7)
Entry Size
/video (default) 26.61 kB
/video (default + hls) 158.98 kB
/video (minimal) 24.97 kB
/video (minimal + hls) 157.28 kB
/audio (default) 24.75 kB
/audio (minimal) 23.16 kB
/background 4.16 kB
Media (8)
Entry Size
/media/background-video 1.04 kB
/media/container 1.73 kB
/media/dash-video 236.51 kB
/media/hls-video 133.61 kB
/media/mux-audio 156.33 kB
/media/mux-video 156.22 kB
/media/native-hls-video 3.62 kB
/media/simple-hls-video 15.87 kB
Players (3)
Entry Size
/video/player 6.37 kB
/audio/player 4.88 kB
/background/player 3.86 kB
Skins (17)
Entry Type Size
/video/minimal-skin.css css 3.47 kB
/video/skin.css css 3.49 kB
/video/minimal-skin js 24.97 kB
/video/minimal-skin.tailwind js 25.19 kB
/video/skin js 26.62 kB
/video/skin.tailwind js 26.82 kB
/audio/minimal-skin.css css 2.53 kB
/audio/skin.css css 2.50 kB
/audio/minimal-skin js 23.12 kB
/audio/minimal-skin.tailwind js 23.25 kB
/audio/skin js 24.67 kB
/audio/skin.tailwind js 24.83 kB
/background/skin.css css 117 B
/background/skin js 1.15 kB
/base.css css 157 B
/shared.css css 88 B
/skin-element js 1.35 kB
UI Components (23)
Entry Size
/ui/alert-dialog 1.01 kB
/ui/alert-dialog-close 479 B
/ui/alert-dialog-description 373 B
/ui/alert-dialog-title 377 B
/ui/buffering-indicator 1.84 kB
/ui/captions-button 2.08 kB
/ui/controls 1.75 kB
/ui/error-dialog 2.46 kB
/ui/fullscreen-button 2.10 kB
/ui/hotkey 2.21 kB
/ui/mute-button 2.11 kB
/ui/pip-button 2.08 kB
/ui/play-button 2.04 kB
/ui/playback-rate-button 2.08 kB
/ui/popover 1.83 kB
/ui/poster 1.61 kB
/ui/seek-button 2.06 kB
/ui/slider 1.53 kB
/ui/thumbnail 2.33 kB
/ui/time 2.04 kB
/ui/time-slider 3.38 kB
/ui/tooltip 2.00 kB
/ui/volume-slider 2.19 kB

Sizes are marginal over the root entry point.

⚛️ @videojs/react — no changes
Presets (7)
Entry Size
/video (default) 21.41 kB
/video (default + hls) 153.87 kB
/video (minimal) 19.93 kB
/video (minimal + hls) 152.45 kB
/audio (default) 18.18 kB
/audio (minimal) 16.71 kB
/background 754 B
Media (7)
Entry Size
/media/background-video 575 B
/media/dash-video 236.42 kB
/media/hls-video 133.55 kB
/media/mux-audio 156.34 kB
/media/mux-video 156.26 kB
/media/native-hls-video 3.65 kB
/media/simple-hls-video 15.92 kB
Skins (14)
Entry Type Size
/video/minimal-skin.css css 3.40 kB
/video/skin.css css 3.42 kB
/video/minimal-skin js 19.83 kB
/video/minimal-skin.tailwind js 23.30 kB
/video/skin js 21.34 kB
/video/skin.tailwind js 23.39 kB
/audio/minimal-skin.css css 2.43 kB
/audio/skin.css css 2.39 kB
/audio/minimal-skin js 16.65 kB
/audio/minimal-skin.tailwind js 19.13 kB
/audio/skin js 18.10 kB
/audio/skin.tailwind js 19.13 kB
/background/skin.css css 90 B
/background/skin js 272 B
UI Components (19)
Entry Size
/ui/alert-dialog 1.13 kB
/ui/buffering-indicator 1.05 kB
/ui/captions-button 2.18 kB
/ui/controls 1.61 kB
/ui/error-dialog 1.54 kB
/ui/fullscreen-button 2.18 kB
/ui/mute-button 2.16 kB
/ui/pip-button 2.18 kB
/ui/play-button 2.19 kB
/ui/playback-rate-button 2.19 kB
/ui/popover 1.80 kB
/ui/poster 1.43 kB
/ui/seek-button 2.14 kB
/ui/slider 3.09 kB
/ui/thumbnail 1.84 kB
/ui/time 1.75 kB
/ui/time-slider 2.74 kB
/ui/tooltip 2.31 kB
/ui/volume-slider 2.77 kB

Sizes are marginal over the root entry point.

🧩 @videojs/core — no changes
Entries (8)
Entry Size
. 5.29 kB
/dom 11.16 kB
/dom/media/custom-media-element 1.91 kB
/dom/media/dash 235.94 kB
/dom/media/hls 132.95 kB
/dom/media/mux 155.72 kB
/dom/media/native-hls 2.97 kB
/dom/media/simple-hls 15.31 kB
🏷️ @videojs/element — no changes
Entries (2)
Entry Size
. 999 B
/context 943 B
📦 @videojs/store — no changes
Entries (3)
Entry Size
. 1.38 kB
/html 696 B
/react 360 B
🔧 @videojs/utils — no changes
Entries (10)
Entry Size
/array 104 B
/dom 1.74 kB
/events 319 B
/function 327 B
/object 247 B
/predicate 265 B
/string 148 B
/style 190 B
/time 478 B
/number 158 B
📦 @videojs/spf — no changes
Entries (3)
Entry Size
. 40 B
/dom 13.27 kB
/playback-engine 13.10 kB

ℹ️ How to interpret

All sizes are standalone totals (minified + brotli).

Icon Meaning
No change
🔺 Increased ≤ 10%
🔴 Increased > 10%
🔽 Decreased
🆕 New (no baseline)

Run pnpm size locally to check current sizes.

Include the CLI package in the linked-versions group so it gets
versioned and published alongside the other packages.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The CLI depends on site build output, which would drag the entire site
build into `build:packages`. Exclude it with a negative filter and add
a dedicated `build:cli` step to the CD workflow that runs after packages
and CDN builds.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Aligns with other published packages in the monorepo.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Fix flaky config test mock (stable temp dir instead of per-call Date.now)
- Add path traversal guard in readBundledDoc and readLlmsTxt
- Validate config keys and values in setConfigValue/getConfigValue
- Fix --install-method help text to reflect actual defaults per framework
- Add site-aliases test to fail loudly if aliased source files move
- Narrow codegen function signatures with Pick<> to remove dummy params
- Consolidate __CLI_VERSION__ declaration into env.d.ts
- Consolidate Framework type into config.ts
- Replace unsafe cast with runtime guard in formatReactInstallation
- Derive site path from workspace root in copy-docs.js
- Clean up unused imports in config test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
decepulis and others added 2 commits April 10, 2026 14:06
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add ambient type stubs for site module imports so tsc can typecheck
- Add "types": ["node"] to CLI tsconfig for Node globals
- Defer --skin flag resolution until preset is known (fixes wrong
  skin when --skin is passed without --preset)
- Remove per-preset renderer validation (any media type works with
  any preset; the UI recommends but doesn't enforce)
- Make copy-docs.js exit 1 when site/dist is missing
- Polish help text, add --help to config subcommand
- Add docExistsInAnyFramework early bail, strip llms footer from output
- Improve LLM markdown for installation CLI section
- Bump CLI version to beta.15, remove plan and design doc
- Add docs command integration tests

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@decepulis decepulis marked this pull request as ready for review April 10, 2026 19:53
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ec049dc. Configure here.

function safePath(...segments: string[]): string | null {
const resolved = resolve(DOCS_DIR, ...segments);
if (!resolved.startsWith(resolve(DOCS_DIR))) return null;
return resolved;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Path traversal bypass in safePath directory check

Low Severity

The safePath function's startsWith check doesn't append a trailing path separator to DOCS_DIR, so a crafted slug can escape the docs directory into a sibling directory whose name shares the same prefix. For example, if DOCS_DIR resolves to /path/to/docs, a slug like ../../docs-other/secret resolves to /path/to/docs-other/secret.md, which passes the startsWith("/path/to/docs") check despite being outside the intended directory. The check needs resolve(DOCS_DIR) + '/' as the prefix.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec049dc. Configure here.

process.exit(1);
}
return result;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicated skin-mapping logic across two files

Low Severity

mapSkinFlag in docs.ts and mapRawSkin in prompts.ts contain nearly identical logic — both map a raw skin string ('default'/'minimal') to a typed Skin value based on whether the use case is audio. The only difference is the second parameter type (preset string vs UseCase enum) and how isAudio is derived. This duplication risks inconsistent fixes if the skin mapping logic changes.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec049dc. Configure here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: Docs CLI Command Docs: Make Installation Page LLM-Friendly

1 participant